#include <iostream>
using namespace std;
int main()
{
int x,y,temp,ans;
cin>>x>>y;
if(x<y)
{
temp=x;
x=y;
y=temp;	
}
while(x!=y)
{
x-=y;
if(x<y)
{
temp=x;
x=y;
y=temp;	
}	
}
ans=x;
cout <<ans<<endl;
return 0;	
}
//输入28 7 输出7
